package android.slc.appbase.api.slc.config;

import android.slc.appbase.R;

import com.blankj.utilcode.util.StringUtils;

/**
 * Created by on the way on 2018/9/18.
 */

public class ApiConfig {

    private String token = null;
    private int pageSize = Value.DEF_PAGE_SIZE;

    private String serviceApiAddress;

    private static class Holder {
        private static final ApiConfig instance = new ApiConfig();
    }

    public static ApiConfig getInstance() {
        return Holder.instance;
    }


    private ApiConfig() {
    }

    public String getToken() {
        return token;
    }

    public void setToken(String token) {
        this.token = token;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public String getServiceApiAddress() {
        if (ApiSp.isApplyCacheApi()) {
            return ApiSp.getServiceApiAddress(serviceApiAddress);
        }
        return serviceApiAddress;
    }

    public void setServiceApiAddress(String serviceApiAddress) {
        this.serviceApiAddress = serviceApiAddress;
        ApiSp.setServiceApiAddress(serviceApiAddress, false);
    }

    public static class Key {
        public static final String KEY_AUTO_SEARCH = "autoSearch";
        public static final String KEY_TOKEN = "Authorization";
    }

    public static class Value {
        public static final String API_DOMAIN_NAME = "domain-api";
        //默认的每页个数
        public static final int DEF_PAGE_SIZE = 15;
        //后台定义
        public static final int SUCCEED = 200;//成功
        public static final int BUSINESS_EXCEPTIONS = 400;//后台提示
        public static final int NORMAL_UNAUTHORIZED = 401;//请求未授权
        public static final int NORMAL_ERROR = 500;//后台提示
        public static final int A_KNOWN_ERROR = 501;//已知错误
        //客户端定义
        public static final int RESULT_UPLOAD_FAILURE = 30003;//上传文件失败
        public static final String RESULT_UPLOAD_FAILURE_MSG = StringUtils.getString(R.string.label_file_upload_by_file_failed);//返回结果list为空提示
    }
}